/**
 *
 */
package com.angel.data.generator.builders.impl;

import java.util.Collection;

import com.angel.dao.generic.factory.DAOFactory;
import com.angel.data.generator.base.DataGeneratorRunner;
import com.angel.data.generator.base.impl.DataGeneratorRunnerImpl;
import com.angel.data.generator.builders.DataGeneratorRunnerBuilder;
import com.angel.data.generator.checkers.DataGeneratorChecker;
import com.angel.data.generator.interfaces.DataGenerator;
import com.angel.data.generator.preProcess.PreProcessStrategy;
import com.angel.data.generator.validators.impl.DataGeneratorClassInheritValidator;

/**
 *
 * @author William
 * @since 21/August/2009.
 *
 */
public class DataGeneratorRunnerImplBuilder extends DataGeneratorRunnerBuilder{

	private DataGeneratorRunnerImpl dataGeneratorRunnerImpl;

	private DAOFactory daoFactory;


    public DataGeneratorRunnerImplBuilder(){
        super();
        dataGeneratorRunnerImpl = new DataGeneratorRunnerImpl();
    }

    public DataGeneratorRunnerImplBuilder(Collection<DataGeneratorChecker> dataGeneratorCheckers){
        super(dataGeneratorCheckers);
        dataGeneratorRunnerImpl = new DataGeneratorRunnerImpl();
    }

    public DataGeneratorRunnerImplBuilder(Collection<DataGeneratorChecker> dataGeneratorCheckers, PreProcessStrategy preProcessStrategy){
        super(dataGeneratorCheckers, preProcessStrategy);
        dataGeneratorRunnerImpl = new DataGeneratorRunnerImpl();
    }

    public DataGeneratorRunner buildDataGeneratorRunner(){
    	dataGeneratorRunnerImpl.addDataGeneratorCheckers(super.getCheckerRunner().getCheckers());
    	dataGeneratorRunnerImpl.setPreProcessStrategy(super.getPreProcessStrategy());
    	dataGeneratorRunnerImpl.setDaoFactory(this.getDaoFactory());
    	return dataGeneratorRunnerImpl;
    }

    @SuppressWarnings("unchecked")
	public <T> void addDataGeneratorClass(Class<T> dataGeneratorClass){
    	Class<? extends DataGenerator> dataGeneratorClassCasted = (Class<? extends DataGenerator>) dataGeneratorClass;
    	dataGeneratorRunnerImpl.addDataGeneratorClass(dataGeneratorClassCasted);
    }

	/**
	 * @return the daoFactory
	 */
	public DAOFactory getDaoFactory() {
		return daoFactory;
	}

	/**
	 * @param daoFactory the daoFactory to set
	 */
	public void setDaoFactory(DAOFactory daoFactory) {
		this.daoFactory = daoFactory;
	}

	@Override
	protected void initializeValidators() {
		super.addDataGeneratorBuilderValidator(new DataGeneratorClassInheritValidator());

	}
}
